package com.rockcent.mall.lib.repository;

import com.rockcent.common.domain.enumclass.Whether;
import com.rockcent.mall.lib.domain.CustomerCouponWallet;
import com.rockcent.mall.lib.domain.enumclass.CustomerCouponWalletSource;
import com.rockcent.mall.lib.domain.enumclass.CustomerCouponWalletStatus;
import com.rockcent.mall.lib.domain.enumclass.OrderVerificationWay;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * Created by zhangjh 2016/10/8.
 */
@Repository
public interface CustomerCouponWalletRepository extends JpaRepository<CustomerCouponWallet, Long>, JpaSpecificationExecutor, CustomerCouponWalletRepositoryCustom {

    List<CustomerCouponWallet> findByCustomerId(Long customerId);

    CustomerCouponWallet findByCustomerIdAndCouponIdAndStatus(Long customerId, Long couponId, CustomerCouponWalletStatus status);

    List<CustomerCouponWallet> findByCustomerIdAndCouponIdAndSource(Long customerId, Long couponId, CustomerCouponWalletSource source);

    CustomerCouponWallet findByVerifyCodeAndStatusAndIsDelete(String verifyCode, CustomerCouponWalletStatus toUse, Whether no);

    CustomerCouponWallet findByVerifyKeyAndStatusAndIsDelete(String verifyKey, CustomerCouponWalletStatus toUse, Whether no);

    Long countByCustomerIdAndStatusAndIsDelete(Long customerId, CustomerCouponWalletStatus status, Whether whether);

    CustomerCouponWallet findByCustomerIdAndCouponIdAndStatusAndVerificationWayAndVerifyCode(Long id, Long couponId, CustomerCouponWalletStatus used, OrderVerificationWay scan, String verifyCode);

    List<CustomerCouponWallet> findByCouponId(Long couponId);

    CustomerCouponWallet findByIdAndCustomerId(Long id, Long customerId);


    CustomerCouponWallet findByIntegrationCouponId(Long integrationCouponId);

    CustomerCouponWallet findByIdAndCustomerIdAndStatus(Long buyCouponWalletId, Long id, CustomerCouponWalletStatus toUse);

}
